#ifndef CLOTH_SCENE_H
#define CLOTH_SCENE_H

#include <NxScene.h>
#include <NxTriangleMeshShapeDesc.h>
#include <cloth/NxCloth.h>

#include "..\_Utils\src\Scene.h"
#include "..\_Utils\src\Stream.h"
#include "..\_Utils\src\modelloader\Model.h"

#include "Renderer.h"
#include "PhysxLogic.h"

class ClothScene : Scene
{
private:
    NxCloth *testcloth;
    NxSoftBody *testSoftBody;
public:
    ClothScene();
    ~ClothScene();

    void PrepareScene(NxScene *scene);
    void CleanScene();

    NxCloth *CreateCloth(const NxVec3 &pos, int numX, int numY, float distance, NxScene *scene);
    NxCloth *CreateClothBox(const NxVec3 &pos, const NxVec3 &size, NxScene *scene);
    NxCloth *CreateClothFromMesh(const NxVec3 &pos, NxTriangleMeshShapeDesc *triMeshShapeDesc, NxScene *scene);
    NxSoftBody *CreateSoftBodyBox(const NxVec3 &pos, const NxVec3 &size, NxScene *scene);

    NxMeshData *CreateReceiveBuffer(int maxVertices, int maxIndices);
    inline int GetFlatIndex(int sizeY, int sizeZ, int index1, int index2, int index3) {
            return (index1*sizeY + index2) * sizeZ + index3;
    }

    void Update();
    void Draw();

    void HandleKeyboardEvent(unsigned char key, int x, int y);
    void HandleKeyboardSpecialEvent(int key, int x, int y);
    void HandleMouseClickEvent(int button, int state, int x, int y);
    void HandleMousePressedMovementEvent(int x, int y, int dx, int dy);
};

#endif //CLOTH_SCENE_H